<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>办理人、办理事项基本信息</title>
<%@ include file="/main/main_css.jsp"%>
<%@ include file="/main/main_js.jsp"%>
<script type="text/javascript" src="static/js/jsAddress.js"></script>
<script src="JS/main.js"></script>
</head>
<body>
	<!--  -->
	<div class="all-wrapper">
		<div class="row com-header text-center">
			<span>鹰潭市行政服务中心</span>
		</div>
		<div class="row main-content table-details">
			<div class="row" >
                <div class="time-count pull-right">
                   <span>剩余</span> <span id="time" class="text-red"></span> <span>秒</span>
                </div>
            </div>
			<div class="row">
				<div class="col-md-24">
					<h1>${uInfo.ITEMNAME }</h1>
				</div>
				<form id="FD"  class="form-horizontal"  action="saveiteminfo" method="post">
					<div class="row">
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">收件人姓名：</label>
								<div class="col-md-15">
									<input id="SJR" maxlength="15" name="name"
										value="${uInfo.REALNAME }" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">手机号：</label>
								<div class="col-md-15">
									<input id="SJH" maxlength="11" name="phone"
										value="${uInfo.MOBILE_NUM}" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">身份证号码：</label>
								<div class="col-md-15">
									<input id="SFZ" maxlength="18" name="agentId"
										value="${uInfo.IDCARD }" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">事项证照是否邮寄：</label>
								<div class="col-md-15">
									<label class="radio-inline"> <input type="radio"
										name="isExprecss" class="inlineRadio1" id="inlineRadio1"
										value="1"> 邮寄
									</label> <label class="radio-inline"> <input type="radio"
										checked="checked" name="isExprecss" id="inlineRadio2"
										value="2"> 自取
									</label>
								</div>
							</div>
						</div>

						<input type="hidden" name="userid" value="${uInfo.USERID }" /> <input
							type="hidden" name="itemId" value="${uInfo.ITEMID }" /> <input
							type="hidden" name="itemsxbm" value="${uInfo.SXBM }" /> <input
							type="hidden" name="register" value="${uInfo.ITEMNAME }" /> <input
							type="hidden" name="idcard" value="${uInfo.IDCARD }" /> <input
							type="hidden" name="enterpriseName" value="${uInfo.REALNAME }" />
						<input type="hidden" name="userType" value="${uInfo.USERDUTY }" />
						<input type="hidden" name="businesslicence"
							value="${uInfo.BUSINESSLICENCE}" /> <input type="hidden"
							name="DYNAMICFORM" value="${uInfo.DYNAMICFORM}" /> <input
							type="hidden" name="FILEDATA" value="${uInfo.FILEDATA}" />
					</div>
					<div class="row item hidden">
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">省：</label>
								<div class="col-md-15">
									<select id="cmbProvince" name="cmbProvince" class="form-control input-lg"></select>
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">市：</label>
								<div class="col-md-15">
									<select id="cmbCity" name="cmbCity" class="form-control input-lg"></select>
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">区: </label>
								<div class="col-md-15">
									<select id="cmbArea" name="cmbArea" class="form-control input-lg"></select>
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">邮政编码：</label>
								<div class="col-md-15">
									<input type="text" maxlength="18" id="yzbm" name="yzbm"
										value="" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">收货地址：</label>
								<div class="col-md-15">
									<input type="text" maxlength="28" id="address"  name="address"
										value="" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7"></label>
								<div class="col-md-15">
									<input type="hidden" maxlength="18" name="isDefault"
										value="0" class="form-control input-lg" />
								</div>
							</div>
						</div>
					</div>
			</div>
			</form>

		</div>
		<div class="row footer">
			<a class="btn btn-success btn-lg" href="loginOut" role="button"><i
				class="fa fa-reply"></i>返回首页</a>
			<button class="btn btn-primary btn-lg" id="submit">
				<i class="fa fa-hand-pointer-o"></i>保存信息
			</button>

		</div>

		<form id="loginOut" action="loginOut"></form>
</body>
<script src="static/plugins/icheck-1.x/icheck.min.js"
	type="text/javascript"></script>
<script>
	//加入倒计时
	var count =  119;
	function countdown(){
		$("#time").text(count);
		if(count > 0){
			window.setTimeout("countdown()",1000);
			count --;
		}else{
			$("#loginOut").submit();
		}
	}
	countdown();
	
	//页面加载动画
	var index = layer.load(3, {
    shade: [0.3,'#000'] //0.1透明度的白色背景  
	});
	setTimeout(function(){
	    layer.close(index);
	},500);

	$('.radio-inline input').iCheck({
		checkboxClass : 'icheckbox_square-blue',
		radioClass : 'iradio_square-blue',
		increaseArea : '20%' // optional
	});
	$('input').on('ifChecked', function(event) { //如果选择邮寄 显示邮寄地址,选择自取 隐藏邮寄地址
		var val = $('input:radio[name="isExprecss"]:checked').val();
		if (val == 1) {
			$('.item').removeClass('hidden');
		} else if (val == 2) {
			$('.item').addClass('hidden');
		}
	});
</script>
<script>
	//绑定打开触摸板接口
	//修改收件人姓名时调用
	$("#SJR").click(function() {
		var info = $("#SJR").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#SJR").val(data.msg);
		});
	});
	//修改手机号时调用
	$("#SJH").click(function() {
		var info = $("#SJH").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#SJH").val(data.msg);
		});
	});
	//修改身份证时调用
	$("#SFZ").click(function() {
		var info = $("#SFZ").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#SFZ").val(data.msg);
		});
	});
	//修改邮政编码时调用
	$("#yzbm").click(function() {
		var info = $("#yzbm").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#yzbm").val(data.msg);
		});
	});
	//修改收货地址时调用
	$("#address").click(function() {
		var info = $("#address").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#address").val(data.msg);
		});
	});

	//页面表单校验
	// 验证中文名称
	function isChinaName(name) {
		var pattern = /^[\u4E00-\u9FA5]{1,6}$/;
		return pattern.test(name);
	}

	// 验证手机号
	function isPhoneNo(phone) {
		var pattern = /^1[345678]\d{9}$/;
		return pattern.test(phone);
	}

	// 验证身份证 
	function isCardNo(card) {
		var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
		return pattern.test(card);
	}
	
	//验证邮编
	function isYzbm(yzbm){
		var pattern = /^[1-9][0-9]{5}$/;
		return pattern.test(yzbm);
	}
	
	

	// 验证函数
	function formValidate(flag) {
		var str = '';

		// 判断名称
		if ($.trim($('#SJR').val()).length == 0) {
			str += '名称没有输入\n';
			$('#SJR').focus();
		} else {
			if (isChinaName($.trim($('#SJR').val())) == false) {
				str += '名称不合法\n';
				$('#SJR').focus();
			}
		}

		// 判断手机号码
		if ($.trim($('#SJH').val()).length == 0) {
			str += '手机号没有输入\n';
			$('#SJH').focus();
		} else {
			if (isPhoneNo($.trim($('#SJH').val())) == false) {
				str += '手机号码不正确\n';
				$('#SJH').focus();
			}
		}

		// 验证身份证
		if ($.trim($('#SFZ').val()).length == 0) {
			str += '身份证号码没有输入\n';
			$('#SFZ').focus();
		} else {
			if (isCardNo($.trim($('#SFZ').val())) == false) {
				str += '身份证号不正确\n';
				$('#SFZ').focus();
			}
		}
		
		if(flag){
			// 验证地址
			 if($.trim($('#address').val()).length == 0) { 
			  str += '地址没有输入\n';
			  $('#address').focus();
			 }
			
			//验证邮编
			if($.trim($('#yzbm').val()).length == 0){
				str += '邮政编码没有输入\n';
				$('#yzbm').focus();
			}else {
				if(isYzbm($.trim($('#yzbm').val())) == false){
					str +='邮政编码不正确\n';
					$('#yzbm').focus();
				}
			}
		}
		// 如果没有错误则提交
		if (str != '') {
			layer.alert(str);
			return false;
		} else {
			$('#FD').submit();
		}
	}

	$('#submit').on('click', function() {
		var flag = false;
		var val = $('input:radio[name="isExprecss"]:checked').val();
		if (val == 1) {
			flag = true;
		} else if (val == 2) {
			flag = false;
		}
		formValidate(flag);
	});
	
	//省市区三级联动下拉框
	addressInit('cmbProvince', 'cmbCity', 'cmbArea');
</script>
<script src="static/js/common.js" type="text/javascript"></script>
</html>